package com.rabbitmq.rabbitmq.config;

import com.rabbitmq.client.ConnectionFactory;
import org.springframework.amqp.core.AcknowledgeMode;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;

/**
 * 添加消息队列
 */
@Configuration
public class MessageConfig {

	@Value("${mq.quenue.string}")
	private String strQueue;

	@Value("${mq.quenue.user}")
	private String userQueue;

	@Value("${mq.topicexchange.string}")
	private String  strExchange;




	@Bean
	public Queue createStringQueue(){
		return  new Queue(strQueue,false,false,false);
	}

	@Bean
	public TopicExchange createStringExchange(){
		return new TopicExchange(strExchange);
	}



	@Bean
	public  Queue createUserQueue(){
		return new Queue(userQueue,true,false,false);
	}

	@Bean
	Binding bindingUser() {
		return BindingBuilder.bind(createUserQueue()).to(createStringExchange()).with("caicai-user-routingKey");
	}
	@Bean
	Binding binding() {
		return BindingBuilder.bind(createStringQueue()).to(createStringExchange()).with("caicai-str-routingKey");
	}







}
